package net.sansi.v3correctserver.config;

import net.sansi.v3correctserver.interceptor.AuthInterceptor;
import net.sansi.v3correctserver.interceptor.CorsInterceptor;
import net.sansi.v3correctserver.interceptor.ProjectInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * Created by Fang
 * create time : 2024/11/11
 * IDE : IntelliJ IDEA
 */

@Configuration
public class InterceptorConfiguration implements WebMvcConfigurer {
    @Resource
    private CorsInterceptor corsInterceptor;

    @Resource
    private AuthInterceptor authInterceptor;

    @Resource
    private ProjectInterceptor projectInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 允许跨域
        registry.addInterceptor(corsInterceptor)
                .addPathPatterns("/**");
        // 权限验证
        //registry.addInterceptor(authInterceptor)
        //        .addPathPatterns("/**");

        // 项目
        registry.addInterceptor(projectInterceptor)
                .addPathPatterns("/**");
    }
}
